﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using YLPublicService.TransferModel;
using YLClient.YLServiceClient;

namespace YLClient.Util
{
    class TemplateManager
    {

        public TemplateItem[] templates;
        private TemplateManager()
        {

        }
        static TemplateManager templateManager;
        /// <summary>
        /// 第一次获取后缓存起来。
        /// </summary>
        /// <returns></returns>
        public static TemplateManager GetTemplateManager()
        {
            if (templateManager == null)
            {
                var templates =
                    ServiceClient.GetServiceClient()
                    .GetEnableTemplates()
                    .ToArray();
                TemplateManager tm = new TemplateManager();
                tm.templates = templates;
                templateManager = tm;
            }
            return templateManager;
        }
        /// <summary>
        /// 重新获取模板
        /// </summary>
        /// <returns></returns>
        public static TemplateManager RefleshGetTemplateManager()
        {
            templateManager = null;
            return GetTemplateManager();
        }
    }
}
